{% extends "StartGroup/groupHome.html" %}
{% block extra_js %}
<script src="/static_media/contifyuser/js/jquery-1.4.2.min.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
    
    $('#add_choice').click(function(){
        var count = $('#id_choice_count').val();
        count = parseInt(count) + 1;
        // Add the new choice
        if(count>6){
            alert('Chutiye Kya Kar raha hai!!');
            return false;
        }
        else {
            $('#id_choice_count').val(count);
            $('#add_choice').prev().after('<div class="CreateChoiceFormFieldLine"><div class="nobreak CreateChoiceFormLabel"><span><strong><label for="id_choice_"+count>Choice</label></strong></span></div><div class="nobreak CreateChoiceFormField"><input type="text" id="id_choice_"+count name="choice" size="25" /><input class="delete_choice" type="button" value="Delete" /></div>&nbsp;<p></p></div>');
            return true;
        }
    });
        
    $('input.delete_choice').live("click", function(){
        var count = $('#id_choice_count').val();
        count = parseInt(count) - 1;
        $('#id_choice_count').val(count);
        $(this).parent().parent().remove();
        return true;
    });

});
</script>
{% endblock %}


{% block create_poll %}
{% if permission == "Owner" or permission == "Board Member" or permission == "Assistant Board Member" %}
<form method="POST" id="poll_form" action="/connectpeople/{{ group.group_web_address }}/polls/add/">
    <div class="CreatePollFormFieldLine">
        <div class="nobreak CreatePollFormLabel"><span><strong>{{ poll_form.poll_topic.label_tag }}</strong></span></div>
        <div class="nobreak CreatePollFormField">{{ poll_form.poll_topic }}</div>
        &nbsp;<p>{{ poll_form.errors.poll_topic }}</p>
    </div>
    <div class="CreatePollFormHiddenFieldLine">
        <div class="nobreak createPollFormField">{{ poll_form.choice_count }}</div>
    </div>
    <br />
    <br />
    {% for choice in choice_forms %}
        <div class="CreateChoiceFormFieldLine">
            <div class="nobreak CreateChoiceFormLabel"><span><strong>{{ choice.choice.label_tag }}</strong></span></div>
            <div class="nobreak CreateChoiceFormField">{{ choice.choice }}</div>
             <!-- &nbsp;<p>{{ choice.errors.choice }}</p> -->
        </div>
    {% endfor %}
    <input type='button' value='Add another Choice' id='add_choice'>
    <br />
    <br />
    <input type="submit" value="Create Poll"/>
</form>
{% else %}
    You need Group Owner, Board Member or Assistant Board Member permission to create new poll.
{% endif %}
{% endblock %}
{% block content %}{% endblock %}


